//Project: Tenpenny Stories version 0.2 beta
//Coding by: Joshua Black aka JABHackSoul
//Questions email to jabhacksoul@yahoo.com
//Audio Splicing: Vincent Black aka ToonSkull/Evol Child 
//Additional Voices: Vincent Black and Brian Black aka Our Dad as Pendelbury
//Scripting Assistance: ZAZ & ceedj on GTAforums.com
//Ideas used: (coming soon!)  Submit Ideas to http://www.thegtaplace.com care of ToonSkull
//Gunia Pig Beta Testers here: (coming soon!) Bugs http://www.thegtaplace.com care of Jabhacksoul
//This script was produced for educational purposes.
//IF you redistribute DON'T REMOVE these comments they help others learn.
//You can add as much as you like but comment on the changes and improvements you made.
// Don't remove old buggy code just comment it out and explain why it was removed.
DEFINE MISSIONS 1              // Total Missions Available
DEFINE MISSION 0 AT @MISSN_05

DEFINE EXTERNAL_SCRIPTS 0 

DEFINE UNKNOWN_EMPTY_SEGMENT 0

DEFINE UNKNOWN_THREADS_MEMORY 500

{$VERSION 3.1.0027}
var
 $PLAYER_CHAR: Player
end // var 
//Main thread starts here
03A4: name_thread 'MAIN' 
//Set the screen BLACK immediately
016A: fade 0 time 0           
01F0: set_max_wanted_level_to 6 
0111: toggle_wasted_busted_check 0 
00C0: set_current_time_hours_to 8 minutes_to 0 
//Loads Tenpenny as #SPECIAL01 or 290
023C: load_special_actor 'TENPEN' as 1 
//Create Player at Station
04E4: unknown_refresh_game_renderer_at 1541 -1675.4 
Camera.SetAtPos(1541.156, -1675.352, 13.55)
$PLAYER_CHAR = Player.Create(#NULL, 1541.156, -1675.352, 13.552)
Player.SetClothes($PLAYER_CHAR, "VEST", "VEST", Torso)
Player.SetClothes($PLAYER_CHAR, "JEANSDENIM", "JEANS", Legs)
Player.SetClothes($PLAYER_CHAR, "SNEAKERBINCBLK", "SNEAKER", Shoes)
Player.SetClothes($PLAYER_CHAR, "PLAYER_FACE", "HEAD", Head)  
Player.Build($PLAYER_CHAR)
//Changes the player to ped model 290 Tenpenny
09C7: change_player $PLAYER_CHAR model_to 290 
01F5: $PLAYER_ACTOR = create_player_actor $PLAYER_CHAR 
07AF: $PLAYER_GROUP = player $PLAYER_CHAR group 
Model.Load(#COPBIKE)
Model.Load(#COPCARLA)
Model.Load(#DESERT_EAGLE)
Model.Load(#COLT45)
038B: load_requested_models 

:MAIN_110
if or
not Model.Available(#COPBIKE)
not Model.Available(#COPCARLA)
not Model.Available(#DESERT_EAGLE)
not Model.Available(#COLT45)
else_jump @MAIN_120 
wait 0 
jump @MAIN_110 
:MAIN_120
0674: set_car_model #COPCARLA numberplate "_CRASH_"
$My_Car = Car.Create(#COPCARLA,  1535.743, -1678.094, 13.09914)
$My_Bike = Car.Create(#COPBIKE, 1535.743, -1665.094, 13.09914)
Car.SetImmunities($My_Car, 0, 1, 0, 0, 0) 
Car.Angle($My_Car) = 0                       //Headed North
Car.DoorStatus($My_Car, 0)                   //No locked doors
053F: set_car $My_Car tires_vulnerability 0  //No popped tries


01B6: set_weather 1 
0001: wait 0 ms 
01B4: toggle_player $PLAYER_CHAR can_move false //We shut down control for the cameras to work 
04BB: select_interior 0 
0629: change_integer_stat 181 to 4 
016C: restart_if_wasted_at 2027.77 -1420.52 15.99 angle 137.0 town_number 0 
016D: restart_if_busted_at 1550.68 -1675.49 14.51 angle 90.0 town_number 0 
// Note: your missions have to use the variable defined here
0180: set_on_mission_flag_to $ONMISSION  
0004: $DEFAULT_WAIT_TIME = 250
03E6: remove_text_box 
$MISSION_1 = 2
// START GAME
$ONMISSION = 0 
01B4: toggle_player $PLAYER_CHAR can_move true               
fade 1 1000 
:MAIN_LOOP
0001: wait $DEFAULT_WAIT_TIME ms
00BF: $TIME_HOURS = current_time_hours, $TIME_MINS = current_time_minutes
if and
$ONMISSION == 0
00E1:   player 0 pressed_key 11
jf @MAIN_LOOP
start_mission 0 
0002: jump @MAIN_LOOP 

//-------------Mission 15---------------
//Easy to follow mission "King of the Hill" - Based on The Warriors (also by Rockstar)
:MISSN_05
thread 'MISSN_05' 
$ONMISSION = 1
054C: use_GXT_table 'JABM05' 
0395: clear_area 1 at 2471.6958 -1888.9365 15.0156 radius 90.0 
1@ = 2452.9658
2@ = -1898.7666
0050: gosub @MISSN_05_INT

00D6: if
0112:   wasted_or_busted
004D: jump_if_false @MISSN_05_End
0050: gosub @MISSN_05_LOSE

:MISSN_05_End
0050: gosub @MISSN_05_CLEANUP
004E: end_thread

// Setup the mission  
:MISSN_05_INT
wait 0
Model.Load(102)  //Notice I used the model numbers instead of names
Model.Load(103)  //I knew I was going to need to refference these so
Model.Load(104)  //I used the number so I wouldn't need to bounce between
Model.Load(331)  //this and help files.
Model.Load(333)
Model.Load(336)
Model.Load(337)
Model.Load(338)
if
Model.Available(102) //Ballas 1
Model.Available(103) //Ballas 2
Model.Available(104) //Ballas 3 
Model.Available(331) //#BRASSKNUCKLE
Model.Available(333) //#GOLFCLUB
Model.Available(336) //#BAT
Model.Available(337) //#SHOVEL
Model.Available(338) //#POOLCUE
jf @MISSN_05_INT

//Cut Scene 
00C0: set_current_time_hours_to 1 minutes_to 5 
02A3: enable_widescreen 1 
009A: 70@ = create_actor_pedtype 7 model 104 at 2481.6411 -1889.2788 25.55
Actor.Angle(70@) = 90.0 
03E5: show_text_box 'KOH01'  // The Ballas haven't paid rent for some time now. They must think you're a punk or something.
wait 5000
068D: get_camera_position_to $TEMPVAR_FLOAT_1 $TEMPVAR_FLOAT_2 $TEMPVAR_FLOAT_3 
068E: get_camera_target_point_to $TEMPVAR_FLOAT_4 $TEMPVAR_FLOAT_5 $TEMPVAR_FLOAT_6 
092F: lock_camera_target_point 1 
0930: lock_camera_position 1 
03CB: set_rendering_origin_at $TEMPVAR_FLOAT_1 $TEMPVAR_FLOAT_2 $TEMPVAR_FLOAT_3 
0160: set_camera_point_at $TEMPVAR_FLOAT_4 $TEMPVAR_FLOAT_5 $TEMPVAR_FLOAT_6  mode 2 
0920: point_camera $TEMPVAR_FLOAT_4 $TEMPVAR_FLOAT_5 $TEMPVAR_FLOAT_6  transverse_to 2481.6411 -1889.2788 25.55  time 5000 mode 1 
0936: set_camera $TEMPVAR_FLOAT_1 $TEMPVAR_FLOAT_2 $TEMPVAR_FLOAT_3  position_to 2471.6411 -1889.2788 18.55  time 5000 drop_mode 1 

00BC: show_text_highpriority GXT 'KOH02' time 15000 flag 1 // ~z~Tenpenny! You came here tonight to get paid, tonight the Ballas pay will pay you...
03CF: load_wav 45235 as 1
gosub @MISSN_05_PLAY
00BC: show_text_highpriority GXT 'KOH03' time 10000 flag 1 // ~z~in BLOOD!  
//Vincent did this voice for the mod himself.
03CF: load_wav 45236 as 1
gosub @MISSN_05_PLAY
00BE: text_clear_all 
03E5: show_text_box 'KOH04' // Keep the hill for 3 minutes and survive at all costs!
wait 5000
060A: create_decision_maker_type 2 store_to 34@  //This makes the actor ignore guns.
Actor.Angle($PLAYER_ACTOR) = 90.0
01F7: set_player $PLAYER_CHAR ignored_by_cops 1  //No Cops
03DE: set_pedestrians_density_multiplier_to 0.0  //No Peds
01EB: set_traffic_density_multiplier_to 0.0      //No Cars
4@ = 0                                           //Index
//Build an Army of 20 men with weapon
:MISSN_05_ARMY
wait 0
0209: 28@ = random_int_in_ranges 0 5             //Random number 0 to 5
if                                               //Change it to 0 1 2 6 7 8 
28@ >= 3
then 
28@ += 3
end   
0209: 13@ = random_int_in_ranges 102 105         //Ballas models 102 103 104
0208: 12@ = random_float_in_ranges 1.2 3.5       
009A: 70@ = create_actor_pedtype 7 model 13@ at 1@ 2@ 13.5469
Actor.Angle(70@) = 270.0
01B2: give_actor 70@ weapon 28@ ammo 999999      //Handout weapons
087E: set_actor 70@ weapon_droppable 0           //Weapons dissapear when dead
060B: set_actor 70@ decision_maker_to 34@        //Pissed off!! (see above)
05E2: AS_actor 70@ kill_actor $PLAYER_ACTOR      //Kill Tenpenny
005B: 2@ += 12@
4@ += 1
if 
    2@ >= -1883.1393
then
    2@ = -1898.7666
005B: 1@ += 12@
end
if 
4@ >= 20
jf @MISSN_05_ARMY
//Setup a 3 minute countdown timer
Fade 1 0
$7234 = 180000 
7@ = 10 
50@ = 0
51@ = 0
014E: set_timer_to $7234 type 1 
0890: enable_sound_when_timer $7234 reach 10 seconds
02A3: enable_widescreen 0
092F: lock_camera_target_point 0 
0930: lock_camera_position 0 
02EB: restore_camera_with_jumpcut 
0373: set_camera_directly_behind_player 
//Start the WAR
:MISSN_05_WARS
wait 0

if
00FE:   actor $PLAYER_ACTOR sphere 0 in_sphere 2471.6958 -1888.9365 15.0156 radius 10.0 10.0 10.0 
then
7@ = 10 
jump @MISSN_05_TIME
end

01BD: 50@ = current_time_in_ms
50@ /= 1000 

if
003B: 50@ == 51@
jf @MISSN_05_86
jump @MISSN_05_TIME

:MISSN_05_86
0085: 51@ = 50@
01E5: show_text_1number_highpriority GXT 'KOH05' number 7@ time 1000 flag 1  // ~s~You have ~1~ seconds to return to the hill or be counted out!
7@ -= 1
//Ten second time out.
if
    7@ >= 0
jf @MISSN_05_LOSE
 
:MISSN_05_TIME
if 
    $7234 <= 0
jf @MISSN_05_WARS

:MISSN_05_WIN
03E5: show_text_box 'KOH06'  // Now the Ballas know you are not a punk and paid the rent.
wait 5000
016A: fade 1 time 1500 

:MISSN_05_FADE
wait 0
if
816B:   not fading 
jf @MISSN_05_FADE

$MISSION_TP += 1
$CRASH_TOTAL_PASSED_MISSIONS += 1 
030C: progress_made += 1 
0394: play_music 1 
Player.ClearWantedLevel($PLAYER_CHAR)
01E3: show_text_1number_styled GXT 'M_PASS' number 2500 time 5000 style 1  // MISSION PASSED!~n~~w~$~1~
Player.Money($PLAYER_CHAR) += 2500
$CRASH_MARKER = Marker.CreateIconAndSphere(16, 1541.156, -1675.352, 13.552)
return 

:MISSN_05_LOSE
00BE: text_clear_all
00BA: show_text_styled GXT 'M_FAIL' time 5000 style 1  
$CRASH_MARKER = Marker.CreateIconAndSphere(16, 2471.6958, -1888.9365, 15.0156)
return

//Play Audio
:MISSN_05_PLAY
wait 0
if  
03D0:   wav 1 loaded 
jf @MISSN_05_PLAY

03D1: play_wav 1

:MISSN_05_UNLOAD 
wait 0

if 
03D2:   wav 1 ended 
jf @MISSN_05_UNLOAD 
040D: unload_wav 1
return

:MISSN_05_CLEANUP
// This section is where you clean up the contents of your mission so you can end it
$ONMISSION = 0  
014F: stop_timer $7234
wait 5000 
00BE: text_clear_all 
03DE: set_pedestrians_density_multiplier_to 1.0 
01EB: set_traffic_density_multiplier_to 1.0 
00D8: mission_cleanup 
0051: return

